#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;
typedef unsigned long long ull;
typedef long double ldb;

#define in read()
#define pii pair<int,int>
#define fi first
#define se second
#define FILE(x) freopen(x".in","r",stdin);\
	freopen(x".out","w",stdout);
#define pb push_back
#define vec vector<int>

int read(){int x = 0,sgn = 1;char ch = getchar();for(;!isdigit(ch);ch = getchar()) if(ch == '-') sgn = -1;for(;isdigit(ch);ch = getchar()) x = (x<<1)+(x<<3)+(ch^48);return x*sgn;}

const int N = 5010;

int n,k,a[N],ans,gs[N];
bool f[N][N],g[N][N];

int main (){
#ifndef ONLINE_JUDGE
	freopen("1.in","r",stdin);
#endif
	n = in,k = in; for(int i = 1;i <= n;i++) a[i] = in; f[0][0] = g[n + 1][0] = 1;
	for(int i = 1;i <= n;i++){
		for(int j = 0;j <= k;j++){
			int nsiz = a[i] + j; nsiz = min(nsiz,k);
			f[i][nsiz] |= f[i-1][j]; f[i][j] |= f[i-1][j];
		}
	}
	for(int i = n;i >= 1;i--)
		for(int j = 0;j <= k;j++){
			int nsiz = a[i] + j; nsiz = min(nsiz,k); 
			g[i][nsiz] |= g[i+1][j]; g[i][j] |= g[i + 1][j];
		}
	for(int i = 1;i <= n;i++){
		if(a[i] >= k) continue;
		gs[0] = 1; for(int s = 1;s <= k;s++) gs[s] = gs[s-1] + f[i-1][s];
		bool fl = 0;
		for(int s = 0;s < k && s + a[i] <= k;s++)
			if(g[i+1][s]){
				if(s + a[i] == k) fl = 1;
				else{
					int l = k - s - a[i],r = k - s;
					if(gs[r - 1] - gs[l - 1] > 0) fl = 1;
				}
				if(fl) break;
			}
		for(int s = k - a[i];s < k;s++) if(g[i + 1][s]) {fl = 1;break;}
		if(!fl) ans++;
	}
	printf("%d\n",ans);
	return 0;
}
